<!DOCTYPE html>
<html>
<head>
<include file="Include:meta" />
<title>添加运营周报-目的地运营集团数据管理平台</title>
<include file="Include:style" />
<link rel="stylesheet" href="__PUBLIC__/mobile/css/dropload.css">
<style>
    body{ position: relative; }
    .operate_alert{ position: absolute; }
</style>
</head>
<body style="background: #f3f3f3;">
<form method="post" name="number_validate" id="password_validate" novalidate="novalidate">
<div class="header">
	<a class="close_btn" href="__APP__/Mobile/Project/project_operate_list/id/{$pid}"></a>添加运营周报<button type="button" class="send_btn animate">保存</button>
</div>
<div class="content">
    <div class="operate_label">
        <div class="cont all">
			<input type="hidden" name="action" value="two">
            <input type="hidden" name="week" value="{$week}">
            <input type="hidden" name="pid" value="{$pid}">
            <div class="title">
                <div>选择工作汇报类别</div>
                <p>{$week_detail}</p>
            </div>
            <div class="label_box">
                <foreach name="gzhb" item="vo" key="k">
                    <foreach name="vo['second']" item="wo"  key="kk">
                        <if condition="$wo['third'] eq NULL">
                            <a href="javascript:;" sid="{$wo['id']}" tid="" data-id="{$wo['num']}">{$wo['second_name']}</a>
                        <else/>
                            <foreach name="wo['third']" item="xo" key="kkk">
                            <a href="javascript:;" sid="{$wo['id']}" tid="{$xo['id']}" data-id="{$xo['num']}">{$xo['third_name']}</a>
                            </foreach>
                        </if>
                    </foreach>
                </foreach>
            </div>
        </div>
        <div class="hb_list hide">
            <ul></ul>
        </div>
        
    </div>
</div>
</form>
<!-- 弹出框 -->
<div class="Alert operate_alert">
    <div>
        <p class="operate_label_name">#<span></span>#</p>
        <textarea name="hb_text"></textarea>
        <div class="btn_box clearboth">
            <a class="btn_close float_l" href="javascript:;">取消</a><button class="btn_alert float_r disabled" disabled>确定</button>
        </div>
        <input class="size_input" type="hidden" sid="" tid="">
    </div>
</div>
<include file="Include:javascript" />
<script src="__PUBLIC__/mobile/js/dropload.min.js"></script>
<script>
    $(function(){
        $('.send_btn').click(function(){localStorage.clear();});
        var winh = $(window).height();
        $('.operate_label').css('min-height',winh-44);
        //标签点击
        $('.label_box a').click(function(){
            var data = $(this).attr('data-id'),
                sid = $(this).attr('sid'),
                tid = $(this).attr('tid');

            $(this).addClass('active');
            Mask();
            $('.Alert').fadeIn().find('textarea').focus();
            var text = $(this).text();
            $('.operate_label_name span').html(text);
            $('.size_input').val(data);
            $('.size_input').attr('sid',sid);
            $('.size_input').attr('tid',tid);
        })
        //文本域编辑
        $("[name='hb_text']").bind('input propertychange', function() {  
            var val = $(this).val();
            if(val!=''){
                $(".btn_alert").removeClass("disabled").attr('disabled',false);
            }else{
                 $(".btn_alert").addClass("disabled").attr('disabled',true);
            }
        })
        //弹框取消
        $('.btn_close').click(function(){
            var size = $('.size_input').val();
            $(this).parents('.operate_alert').find('textarea').val('');
            $('.label_box a').eq(size).removeClass('active');
        })
        //弹框确定
        $('.btn_alert').click(function(){
            var _this = $(this),
                val = _this.parents('.operate_alert').find('textarea').val(),
                txt = _this.parents('.operate_alert').find('span').text(),
                size = $('.size_input').val(),
                sid = $('.size_input').attr('sid'),
                tid = $('.size_input').attr('tid'),
                html = '<li><div class="over_box"><div>'+txt+'</div><p>'+val+'</p></div><a class="icon_delete_btn" href="javascript:;"></a><input class="size_input2" type="hidden" value="'+size+'"><input class="size_input2" type="hidden" value="'+val+'" name="content[]"><input class="size_input2" type="hidden" value="'+sid+'" name="sid[]"><input class="size_input2" type="hidden" value="'+tid+'" name="tid[]"></li>';
            $(this).parents('.operate_alert').find('textarea').val('');
            _this.parents('.Alert').fadeOut();
            $('.Mask').fadeOut(function(){
                $(this).remove();
            });
            $('.hb_list').removeClass('hide').find('ul').append(html);
            if($('.hb_list li').length == $('.label_box a').length){
                $('.header .send_btn').addClass('active');
            }
            $(".btn_alert").addClass("disabled").attr('disabled',true);
        })
        //删除
        $("body").on('click','.icon_delete_btn',function(){
            modal_alert('您确定要删除吗？');
            $(this).parents('li').addClass('tr_det');
        })
        $('body').on('click','.modal_sub',function(){
            $(this).parents('.modal_alert').fadeOut(function(){
                $(this).remove();
            });
            $('.Mask').fadeOut(function(){
                $(this).remove();
            });
            var size = $('.tr_det').find('.size_input2').val();
            $('.tr_det').remove();
            $('.label_box a').eq(size).removeClass('active');
            if($('.hb_list li').length < $('.label_box a').length){
                $('.header .send_btn').removeClass('active');
            }
            if($('.hb_list li').length==0){
                $('.hb_list').addClass('hide');
            }
        });
        $("body").on('click','.modal_close',function(){
            $('.hb_list').find('li').removeClass('tr_det');
        })
        //提交
        $('.send_btn').click(function(){
            $.ajax({
                type: 'POST',
                async:false,
				dataType:"json",
                data:$("[name='number_validate']").serialize(),
                url:"__APP__/Mobile/Project/project_operate_audit",
                dataType: 'json',
                success: function(data){
                    location.href="__APP__/Mobile/Project/project_operate_list/id/"+data.pid+"";
                }
            })
        })
    })
</script>
</body>
</html>